var api = require('../../util/api.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
    onLoad: function () {
        let chain = api.chain();
        this.setData({
            page: api.page(10),
            dataList: [],
            params : {
                examineId : chain.examineId,
                userId : chain.userId
            }
        });
        this.onReachBottom();
    },
    onPullDownRefresh(){
        this.setData({
            page: api.page(5),
            dataList: []
        });
        this.loadList();
    },
    onReachBottom() {
        this.loadList();
    },
    loadList(){
        var _this = this;
        var params = _this.data.params;
        var page = _this.data.page;
        api.get(api.url.zgdList, params, page).then(res => {
            page.setTotal(res.total);
        if (res.rows.length == 0) {
            this.setData({
                hasData: false
            })
        } else {
            _this.setData({
                hasData: true,
                    dataList: _this.data.dataList.concat(res.rows)
                });
            }
            })
    }

})